package com.example.demo.map;

import org.junit.jupiter.api.Test;
import org.springframework.beans.BeanUtils;

import java.math.BigDecimal;
import java.math.BigInteger;
import java.time.*;
import java.time.temporal.TemporalAdjusters;
import java.util.*;

public class main {

    @Test
    public void ssd222() {
        String s = "pages/goodsDetail/GoodsDetail?goodsId=1440862485581272099&utmChannel=123";
        String[] split = s.split("\\?");
        System.out.println(split);

    }

    @Test
    public void ssd23() {
        Long s = 1440970296701095936l;
        // 十进制转十六进制
        String s1 = Long.toHexString(s);
        System.out.println(s1);

        // 十六进制转十进制
        BigInteger bigInteger = new BigInteger(s1, 16);
        System.out.println(bigInteger);

        long l = bigInteger.longValue();
        System.out.println(l);

        Long aLong = Long.valueOf(s1, 10);
        System.out.println(aLong);
    }


    @Test
    public void s() {
        RaiseActivityTask task = new RaiseActivityTask();
        task.setActivityId(112L);
        task.setBrowseTime(123);
        RaiseActivityTaskResp resp = new RaiseActivityTaskResp();
        BeanUtils.copyProperties(task, resp);
        System.out.println(resp.toString());

        RaiseActivityTask task1 = new RaiseActivityTask();
        task1.setActivityId(1123L);
        task1.setBrowseTime(121233);
        BeanUtils.copyProperties(task1, resp);
        System.out.println(resp.toString());
    }

    @Test
    public void test12() {
        HashMap<People, Integer> hashMap = new HashMap<>();

        People people = new People(10, "AAA");
        People people2 = new People(10, "AAA");

        hashMap.put(people, 2);
        hashMap.put(people2, 2);

        for (Map.Entry<People, Integer> entry : hashMap.entrySet()) {
            System.out.println(entry.getKey() + " " + entry.getValue());
        }

        Long s = 213123l;
        System.out.println(s.toString());
        System.out.println(s);
        System.out.println(Long.parseLong(s.toString()));

        Boolean newcomer = false;

        System.out.println(null == newcomer ? false : newcomer);
        System.out.println(null != newcomer);

        System.out.println(String.join(":","123","23", "23123"));
    }

    @Test
    public void tes() {
        LocalDateTime now = LocalDateTime.now();
        LocalDateTime createdTime = now;
        LocalDateTime with = now.minusDays(1).with(TemporalAdjusters.lastDayOfMonth());
        System.out.println(with);
        LocalDateTime with1 = now.plusDays(1).with(TemporalAdjusters.firstDayOfMonth());
        System.out.println(with1);


        LocalDateTime with11 = now.minusDays(1);
        System.out.println(with11);
        LocalDateTime with12 = now.plusDays(1);
        System.out.println(with12);


        boolean create = createdTime.isAfter(now.minusDays(1)) &&
                createdTime.isBefore(now.plusDays(1));
        System.out.println(create);


        LocalDateTime todayStart = LocalDateTime.of(LocalDate.now(), LocalTime.MIN);
        System.out.println(todayStart);
        System.out.println(todayStart.toInstant(ZoneOffset.of("+8")).toEpochMilli());

        LocalDateTime today_end = LocalDateTime.of(LocalDate.now(), LocalTime.MAX);
        System.out.println(today_end);

        Duration timeOut = Duration.between(LocalDateTime.now(), today_end);
        System.out.println(timeOut.getSeconds());

    }

    @Test
    public void ssd2() {
        // 起止 >="
        BigDecimal min = BigDecimal.ZERO;
        // 终点 <
        BigDecimal max = BigDecimal.ZERO;

        String[] s = {"44.5", "23.33", "66.7", "66.7"};

        for (String s1 : s) {
            min = max;
            max = max.add(new BigDecimal(s1));
            System.out.println(min + " , " + max);
        }

        System.out.println(max.multiply(new BigDecimal("100")).intValue());
        Random random = new Random();
        int i = random.nextInt(max.multiply(new BigDecimal("100")).intValue());
        System.out.println(i);
        System.out.println(new BigDecimal(i).divide(new BigDecimal("100")).setScale(2, BigDecimal.ROUND_HALF_UP));


        int bigDecimal = new BigDecimal("2.335").multiply(new BigDecimal("100")).setScale(0, BigDecimal.ROUND_HALF_UP).intValue();
        int bigDecimal1 = new BigDecimal("2.335").multiply(new BigDecimal("100")).intValue();
        System.out.println(bigDecimal);
        System.out.println(bigDecimal1);
    }

    @Test
    public void r() {
        Integer b = 500;
        Integer c = 1500;
        System.out.println(b.compareTo(c)); //输出-1
        System.out.println(b >= c); //输出-1
        System.out.println(b == c); //输出-1
        b = 15000;
        System.out.println(b.compareTo(c)); //输出0
        b = 1500;
        System.out.println(b.compareTo(c)); //输出1);
    }

    @Test
    public void ssd() {
        int a;
        int first, second, third, fouth;

        int days;


        java.util.Random random = new java.util.Random();
        Scanner week = new Scanner(System.in);
        int weeks = 1;
        while (weeks == 1) {
            days = 7;
            int show = 5;
            first = second = third = fouth = 0;
            while (days > 0) {
                fouth = 10;//每天至少10个
                for (int i = 0; i < 100; i++) {
                    a = random.nextInt(5);

                    if (show > 0 && first < 1 && a == 0) {
                        //每周
                        first++;
                        System.out.println("获得一等奖");
                        show--;
                    } else if (show > 0 && second <= 6 && a == 1) {
                        //每周
                        second++;
                        System.out.println("获得二等奖");
                        show--;
                    } else if (show > 0 && third <= 10 && a == 2) {
                        //每周
                        third++;
                        System.out.println("获得三等奖");
                        show--;
                    } else if (show > 0 && fouth <= 10 && a == 3) {
                        fouth--;
                        System.out.println("获得四等奖");
                        show--;
                    } else {
                        //System.out.println("谢谢参与！");
                    }
                }
                days--;
            }

            System.out.println("本周已经结束！\n继续抽奖请输入1，退出输入0\n");
            weeks = week.nextInt();
        }
    }

}
